package com.showcai.admin.controller.user;


import com.github.pagehelper.PageInfo;
import com.showcai.admin.service.UserServiceClient;
import com.showcai.module.vo.News;
import com.showcai.module.vo.User;
import com.showcai.webcore.controller.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2018-6-22.
 */
@Controller
@RequestMapping("user")
public class UserController extends BaseController {
    @Autowired
    UserServiceClient userServiceClient;

    @RequestMapping("/getUser/{id}")
    @ResponseBody
    public User getUser(@PathVariable("id") Long id) {
        User user = new User();
        user= userServiceClient.getUser(id);
        return user;
    }
    @RequestMapping("/get/newsList")
    @ResponseBody
    public List<News> newsList(Map<String, String> map) {
        List<News> newsList= userServiceClient.getNewsList(map);
        return newsList;
    }    @RequestMapping("/get/newsList1")
    @ResponseBody
    public PageInfo newsList1(Map<String, String> map) {
        PageInfo pageInfo= userServiceClient.getNewsList1(map);
        return pageInfo;
    }

    @RequestMapping("/user")
    public ModelAndView user() {
        System.out.println("user===================>>>>");
        ModelAndView mov = new ModelAndView();
        mov.setViewName("/index");
        User user = new User();
        user.setNickName("小明");
        user.setPassWord("xxxx");
        mov.addObject("user", user);
        return mov;
    }
    @RequestMapping(value = "/greeting")
    public ModelAndView test(ModelAndView mv) {
        mv.setViewName("/greeting.html");
        mv.addObject("title","欢迎使用Thymeleaf!");
        return mv;
    }

}
